﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ElementumForever.Editer
{
    public partial class SceneStructureForm : Form
    {
        public SceneStructureForm()
        {
            InitializeComponent();
        }

        public void SetTreeData(EntityInfo data)
        {
            sceneStructureTree.Nodes.Clear();
            SetDataToNode(sceneStructureTree.Nodes, data);
        }

        //add data to this node
        private void SetDataToNode(TreeNodeCollection nodes, EntityInfo data)
        {
            string text = "???";
            TreeNode newNode = new TreeNode(data.Name);
            nodes.Add(newNode);
            if (data.IsTable)
            {
                foreach (EntityInfo sd in data.Table.Values)
                    SetDataToNode(newNode.Nodes, sd);
                text = data.Name;
                if (data.Name == LuaConstants.Color)
                    newNode.ForeColor = EntitySerializer.ToColorForm(data);
            }
            else
            {
                text = data.Name + ": " + data.Value;
            }

            newNode.Text = text;
        }



    }
}
